﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//using VIA.Project.Domain.Devices;

//namespace VIA.SiMoJi.Domain.SoftPLC
//{
//    public static class IOLable
//    {
//        public static Dictionary<int, BitDataRegister> In_PiyshicalBitDataRegisters { get; } = new();
//        public static Dictionary<int, BitDataRegister> Out_PiyshicalBitDataRegisters { get; } = new();
//        public static Dictionary<string, BitDataRegister> Vir_BitDataRegisters { get; } = new();
//        public static void Init()
//        {
//            #region Input Init
//            AddInputPiyshicalBitDataRegister(01, "面板_启动按钮");
//            AddInputPiyshicalBitDataRegister(02, "面板_停止按钮");
//            AddInputPiyshicalBitDataRegister(03, "面板_复位按钮");
//            AddInputPiyshicalBitDataRegister(04, "手动/自动旋钮_手动");
//            AddInputPiyshicalBitDataRegister(05, "手动/自动旋钮_自动");
//            AddInputPiyshicalBitDataRegister(06, "面板_急停按钮");
//            AddInputPiyshicalBitDataRegister(07, "背面_急停按钮");
//            AddInputPiyshicalBitDataRegister(08, "总气源气压表");
//            AddInputPiyshicalBitDataRegister(09, "门禁报警信号1");
//            AddInputPiyshicalBitDataRegister(10, "门禁报警信号2");
//            AddInputPiyshicalBitDataRegister(11, "门禁报警信号3");
//            AddInputPiyshicalBitDataRegister(12, "门禁报警信号4");
//            AddInputPiyshicalBitDataRegister(13, "门禁报警信号5");
//            AddInputPiyshicalBitDataRegister(14, "门禁报警信号6");
//            AddInputPiyshicalBitDataRegister(15, "风扇报警1");
//            AddInputPiyshicalBitDataRegister(16, "风扇报警2");
//            AddInputPiyshicalBitDataRegister(17, "风扇报警3");
//            AddInputPiyshicalBitDataRegister(18, "风扇报警4");
//            AddInputPiyshicalBitDataRegister(19, "入料防追尾光电");
//            AddInputPiyshicalBitDataRegister(20, "入料口光电");
//            AddInputPiyshicalBitDataRegister(21, "入料到位光电");
//            AddInputPiyshicalBitDataRegister(22, "出料口光电");
//            AddInputPiyshicalBitDataRegister(23, "入料到位挡缸1伸出磁开");
//            AddInputPiyshicalBitDataRegister(24, "入料到位挡缸1缩回磁开");
//            AddInputPiyshicalBitDataRegister(25, "入料到位挡缸2伸出磁开");
//            AddInputPiyshicalBitDataRegister(26, "入料到位挡缸2缩回磁开");
//            AddInputPiyshicalBitDataRegister(27, "入料左右拍板气缸1原点磁开");
//            AddInputPiyshicalBitDataRegister(28, "入料左右拍板气缸1伸出磁开");
//            AddInputPiyshicalBitDataRegister(29, "入料左右拍板气缸2原点磁开");
//            AddInputPiyshicalBitDataRegister(30, "入料左右拍板气缸2伸出磁开");
//            AddInputPiyshicalBitDataRegister(31, "入料前后拍板气缸1缩回磁开");
//            AddInputPiyshicalBitDataRegister(32, "入料前后拍板气缸1伸出磁开");
//            AddInputPiyshicalBitDataRegister(33, "入料前后拍板气缸2缩回磁开");
//            AddInputPiyshicalBitDataRegister(34, "入料前后拍板气缸2伸出磁开");
//            AddInputPiyshicalBitDataRegister(35, "入料前后拍板上下气缸1缩回磁开");
//            AddInputPiyshicalBitDataRegister(36, "入料前后拍板上下气缸1伸出磁开");
//            AddInputPiyshicalBitDataRegister(37, "入料前后拍板上下气缸2缩回磁开");
//            AddInputPiyshicalBitDataRegister(38, "入料前后拍板上下气缸2伸出磁开");
//            AddInputPiyshicalBitDataRegister(39, "39");
//            AddInputPiyshicalBitDataRegister(40, "取放料真空表1");
//            AddInputPiyshicalBitDataRegister(41, "取放料真空表2");
//            AddInputPiyshicalBitDataRegister(42, "取放料真空表3");
//            AddInputPiyshicalBitDataRegister(43, "取放料真空表4");
//            AddInputPiyshicalBitDataRegister(44, "取放料真空表5");
//            AddInputPiyshicalBitDataRegister(45, "取放料真空表6");
//            AddInputPiyshicalBitDataRegister(46, "取放料真空表7");
//            AddInputPiyshicalBitDataRegister(47, "取放料顶升气缸缩回磁开");
//            AddInputPiyshicalBitDataRegister(48, "取放料顶升气缸伸出磁开");
//            AddInputPiyshicalBitDataRegister(49, "飞达1压膜缸缩回磁开");
//            AddInputPiyshicalBitDataRegister(50, "飞达1定位缸伸出磁开");
//            AddInputPiyshicalBitDataRegister(51, "飞达1定位缸缩回磁开");
//            AddInputPiyshicalBitDataRegister(52, "飞达1抽屉按钮");
//            AddInputPiyshicalBitDataRegister(53, "飞达2压膜缸缩回磁开");
//            AddInputPiyshicalBitDataRegister(54, "飞达2定位缸伸出磁开");
//            AddInputPiyshicalBitDataRegister(55, "飞达2定位缸缩回磁开");
//            AddInputPiyshicalBitDataRegister(56, "NG下料无杆缸缩回磁开");
//            AddInputPiyshicalBitDataRegister(57, "NG下料无杆缸缩回磁开");
//            AddInputPiyshicalBitDataRegister(58, "NG下料抽屉定位缸伸出磁开");
//            AddInputPiyshicalBitDataRegister(59, "NG下料抽屉定位缸缩回磁开");
//            AddInputPiyshicalBitDataRegister(60, "NG抽屉按钮");
//            AddInputPiyshicalBitDataRegister(61, "NG抽屉闭合光电");
//            AddInputPiyshicalBitDataRegister(62, "NG抽屉打开光电");
//            AddInputPiyshicalBitDataRegister(63, "NG抽屉料盘有无光电");
//            AddInputPiyshicalBitDataRegister(64, "夹爪膜检测光纤1-1");
//            AddInputPiyshicalBitDataRegister(65, "夹爪膜检测光纤1-2");
//            AddInputPiyshicalBitDataRegister(66, "夹爪膜检测光纤1-3");
//            AddInputPiyshicalBitDataRegister(67, "夹爪膜检测光纤1-4");
//            AddInputPiyshicalBitDataRegister(68, "夹爪膜检测光纤1-5");
//            AddInputPiyshicalBitDataRegister(69, "夹爪膜检测光纤1-6");
//            AddInputPiyshicalBitDataRegister(70, "夹爪膜检测光纤1-7");
//            AddInputPiyshicalBitDataRegister(71, "夹爪膜检测光纤2-1");
//            AddInputPiyshicalBitDataRegister(72, "夹爪膜检测光纤2-2");
//            AddInputPiyshicalBitDataRegister(73, "夹爪膜检测光纤2-3");
//            AddInputPiyshicalBitDataRegister(74, "夹爪膜检测光纤2-4");
//            AddInputPiyshicalBitDataRegister(75, "夹爪膜检测光纤2-5");
//            AddInputPiyshicalBitDataRegister(76, "夹爪膜检测光纤2-6");
//            AddInputPiyshicalBitDataRegister(77, "夹爪膜检测光纤2-7");
//            AddInputPiyshicalBitDataRegister(78, "夹爪张开光纤1");
//            AddInputPiyshicalBitDataRegister(79, "夹爪闭合光纤1");
//            AddInputPiyshicalBitDataRegister(80, "夹爪张开光纤2");
//            AddInputPiyshicalBitDataRegister(81, "夹爪闭合光纤2");
//            AddInputPiyshicalBitDataRegister(82, "飞达1抽屉闭合光电");
//            AddInputPiyshicalBitDataRegister(83, "飞达2抽屉闭合光电");
//            AddInputPiyshicalBitDataRegister(84, "85");
//            AddInputPiyshicalBitDataRegister(85, "86");
//            AddInputPiyshicalBitDataRegister(86, "87");
//            AddInputPiyshicalBitDataRegister(87, "88");
//            AddInputPiyshicalBitDataRegister(88, "89");
//            AddInputPiyshicalBitDataRegister(89, "90");
//            AddInputPiyshicalBitDataRegister(90, "91");
//            AddInputPiyshicalBitDataRegister(91, "92");
//            AddInputPiyshicalBitDataRegister(92, "上料交互输入信号1-模组继电器");
//            AddInputPiyshicalBitDataRegister(93, "上料交互输入信号2-模组继电器");
//            AddInputPiyshicalBitDataRegister(94, "下料交互输入信号1-模组继电器");
//            AddInputPiyshicalBitDataRegister(95, "下料交互输入信号2-模组继电器");
//            AddInputPiyshicalBitDataRegister(96, "下料交互输入信号2-模组继电器");
//            #endregion                       

//            #region Output Init
//            AddOutputPiyshicalBitDataRegister(01, "面板_启动按钮灯");
//            AddOutputPiyshicalBitDataRegister(02, "面板_停止按钮灯");
//            AddOutputPiyshicalBitDataRegister(03, "面板_复位按钮灯");
//            AddOutputPiyshicalBitDataRegister(04, "手动/自动按钮灯");
//            AddOutputPiyshicalBitDataRegister(05, "三色灯_红灯(1控2)模组继电器");
//            AddOutputPiyshicalBitDataRegister(06, "三色灯_黄灯(1控2)模组继电器");
//            AddOutputPiyshicalBitDataRegister(07, "三色灯_绿灯(1控2)模组继电器");
//            AddOutputPiyshicalBitDataRegister(08, "三色灯_蜂鸣器(1控2)模组继电器");
//            AddOutputPiyshicalBitDataRegister(09, "门禁锁电源1");
//            AddOutputPiyshicalBitDataRegister(10, "门禁锁电源2");
//            AddOutputPiyshicalBitDataRegister(11, "门禁锁电源3");
//            AddOutputPiyshicalBitDataRegister(12, "门禁锁电源4");
//            AddOutputPiyshicalBitDataRegister(13, "门禁锁电源5");
//            AddOutputPiyshicalBitDataRegister(14, "门禁锁电源6");
//            AddOutputPiyshicalBitDataRegister(15, "入料相机条光触发");
//            AddOutputPiyshicalBitDataRegister(16, "入料相机背光触发");
//            AddOutputPiyshicalBitDataRegister(17, "入料相机触发");
//            AddOutputPiyshicalBitDataRegister(18, "读码相机光源触发");
//            AddOutputPiyshicalBitDataRegister(19, "取放料相机光源触发");
//            AddOutputPiyshicalBitDataRegister(20, "取放料相机触发");
//            AddOutputPiyshicalBitDataRegister(21, "入料到位光电");
//            AddOutputPiyshicalBitDataRegister(22, "日光灯-继电器");
//            AddOutputPiyshicalBitDataRegister(23, "入料到位挡缸伸出电磁阀(1控2)");
//            AddOutputPiyshicalBitDataRegister(24, "入料到位挡缸缩回电磁阀(1控2)");
//            AddOutputPiyshicalBitDataRegister(25, "入料左右拍板气缸缩回电磁阀(1控2)");
//            AddOutputPiyshicalBitDataRegister(26, "入料左右拍板气缸伸出电磁阀(1控2)");
//            AddOutputPiyshicalBitDataRegister(27, "入料前后拍板气缸缩回电磁阀(1控2)");
//            AddOutputPiyshicalBitDataRegister(28, "入料前后拍板气缸伸出电磁阀(1控2)");
//            AddOutputPiyshicalBitDataRegister(29, "入料前后拍板上下气缸缩回电磁阀(1控2)");
//            AddOutputPiyshicalBitDataRegister(30, "入料前后拍板上下气缸伸出电磁阀(1控2)");
//            AddOutputPiyshicalBitDataRegister(31, "31");
//            AddOutputPiyshicalBitDataRegister(32, "32");
//            AddOutputPiyshicalBitDataRegister(33, "取放料真空1吸");
//            AddOutputPiyshicalBitDataRegister(34, "取放料真空1吹");
//            AddOutputPiyshicalBitDataRegister(35, "取放料真空2吸");
//            AddOutputPiyshicalBitDataRegister(36, "取放料真空2吹");
//            AddOutputPiyshicalBitDataRegister(37, "取放料真空3吸");
//            AddOutputPiyshicalBitDataRegister(38, "取放料真空3吹");
//            AddOutputPiyshicalBitDataRegister(39, "取放料真空4吸");
//            AddOutputPiyshicalBitDataRegister(40, "取放料真空4吹");
//            AddOutputPiyshicalBitDataRegister(41, "取放料真空5吸");
//            AddOutputPiyshicalBitDataRegister(42, "取放料真空5吹");
//            AddOutputPiyshicalBitDataRegister(43, "取放料真空6吸");
//            AddOutputPiyshicalBitDataRegister(44, "取放料真空6吹");
//            AddOutputPiyshicalBitDataRegister(45, "取放料真空7吸");
//            AddOutputPiyshicalBitDataRegister(46, "取放料真空7吹");
//            AddOutputPiyshicalBitDataRegister(47, "取放料顶升气缸缩回电磁阀");
//            AddOutputPiyshicalBitDataRegister(48, "取放料顶升气缸伸出电磁阀");
//            AddOutputPiyshicalBitDataRegister(49, "飞达1压膜缸电磁阀");
//            AddOutputPiyshicalBitDataRegister(50, "飞达1定位缸伸出电磁阀");
//            AddOutputPiyshicalBitDataRegister(51, "飞达1定位缸缩回电磁阀");
//            AddOutputPiyshicalBitDataRegister(52, "飞达1抽屉按钮灯");
//            AddOutputPiyshicalBitDataRegister(53, "飞达2压膜缸电磁阀");
//            AddOutputPiyshicalBitDataRegister(54, "飞达2定位缸伸出电磁阀");
//            AddOutputPiyshicalBitDataRegister(55, "飞达2定位缸缩回电磁阀");
//            AddOutputPiyshicalBitDataRegister(56, "飞达2抽屉按钮灯");
//            AddOutputPiyshicalBitDataRegister(57, "NG下料无杆缸缩回电磁阀");
//            AddOutputPiyshicalBitDataRegister(58, "NG下料无杆缸伸出电磁阀");
//            AddOutputPiyshicalBitDataRegister(59, "NG下料抽屉定位缸伸出电磁阀");
//            AddOutputPiyshicalBitDataRegister(60, "NG下料抽屉定位缸缩回电磁阀");
//            AddOutputPiyshicalBitDataRegister(61, "NG抽屉按钮灯");
//            AddOutputPiyshicalBitDataRegister(62, "62");
//            AddOutputPiyshicalBitDataRegister(63, "63");
//            AddOutputPiyshicalBitDataRegister(64, "64");
//            AddOutputPiyshicalBitDataRegister(65, "夹爪气缸1-1张开电磁阀");
//            AddOutputPiyshicalBitDataRegister(66, "夹爪气缸1-1闭合电磁阀");
//            AddOutputPiyshicalBitDataRegister(67, "夹爪气缸2-1张开电磁阀");
//            AddOutputPiyshicalBitDataRegister(68, "夹爪气缸2-1闭合电磁阀");
//            AddOutputPiyshicalBitDataRegister(69, "夹爪气缸3-1张开电磁阀");
//            AddOutputPiyshicalBitDataRegister(70, "夹爪气缸3-1闭合电磁阀");
//            AddOutputPiyshicalBitDataRegister(71, "夹爪气缸4-1张开电磁阀");
//            AddOutputPiyshicalBitDataRegister(72, "夹爪气缸4-1闭合电磁阀");
//            AddOutputPiyshicalBitDataRegister(73, "夹爪气缸5-1张开电磁阀");
//            AddOutputPiyshicalBitDataRegister(74, "夹爪气缸5-1闭合电磁阀");
//            AddOutputPiyshicalBitDataRegister(75, "夹爪气缸6-1张开电磁阀");
//            AddOutputPiyshicalBitDataRegister(76, "夹爪气缸6-1闭合电磁阀");
//            AddOutputPiyshicalBitDataRegister(77, "夹爪气缸7-1张开电磁阀");
//            AddOutputPiyshicalBitDataRegister(78, "夹爪气缸7-1闭合电磁阀");
//            AddOutputPiyshicalBitDataRegister(79, "夹爪气缸2-1张开电磁阀");
//            AddOutputPiyshicalBitDataRegister(80, "夹爪气缸2-1闭合电磁阀");
//            AddOutputPiyshicalBitDataRegister(81, "夹爪气缸2-2张开电磁阀");
//            AddOutputPiyshicalBitDataRegister(82, "夹爪气缸2-2闭合电磁阀");
//            AddOutputPiyshicalBitDataRegister(83, "夹爪气缸2-3张开电磁阀");
//            AddOutputPiyshicalBitDataRegister(84, "夹爪气缸2-3闭合电磁阀");
//            AddOutputPiyshicalBitDataRegister(85, "夹爪气缸2-4张开电磁阀");
//            AddOutputPiyshicalBitDataRegister(86, "夹爪气缸2-4闭合电磁阀");
//            AddOutputPiyshicalBitDataRegister(87, "夹爪气缸2-5张开电磁阀");
//            AddOutputPiyshicalBitDataRegister(88, "夹爪气缸2-5闭合电磁阀");
//            AddOutputPiyshicalBitDataRegister(89, "夹爪气缸2-6张开电磁阀");
//            AddOutputPiyshicalBitDataRegister(90, "夹爪气缸2-6闭合电磁阀");
//            AddOutputPiyshicalBitDataRegister(91, "夹爪气缸2-7张开电磁阀");
//            AddOutputPiyshicalBitDataRegister(92, "夹爪气缸2-7闭合电磁阀");
//            AddOutputPiyshicalBitDataRegister(93, "上料交互输出信号1-模组继电器");
//            AddOutputPiyshicalBitDataRegister(94, "上料交互输出信号2-模组继电器");
//            AddOutputPiyshicalBitDataRegister(95, "下料交互输出信号1-模组继电器");
//            AddOutputPiyshicalBitDataRegister(96, "下料交互输出信号2-模组继电器");
//            #endregion

//            #region Vir_Init
//            AddVirBitDataRegister(1, "自动运行就绪标志");

//            #endregion

//            void AddInputPiyshicalBitDataRegister(int address, string annotation)
//            {
//                ushort add = (ushort)(address + 7);
//                In_PiyshicalBitDataRegisters[address] = new BitDataRegister(add, annotation);
//            }
//            void AddOutputPiyshicalBitDataRegister(int address, string annotation)
//            {
//                ushort add = (ushort)(address + 7);
//                Out_PiyshicalBitDataRegisters[address] = new BitDataRegister(add, annotation);
//            }
//        }

//        public static void AddVirBitDataRegister(int address, string annotation)
//        {
//            Vir_BitDataRegisters[annotation] = new BitDataRegister((ushort)address, annotation) { };
//        }

//        public static BitDataRegister GetVir_BitDataRegister(int address)
//        {
//            var rg = Vir_BitDataRegisters.Values.FirstOrDefault(x => x.Address == address);
//            if (rg == null) throw (new Exception($"寄存器地址{address}未定义！"));
//            return rg;
//        }

//        public static BitDataRegister GetIn_BitDataRegister(string annotation)
//        {
//            var rg = In_PiyshicalBitDataRegisters.Values.FirstOrDefault(x => x.Annotation == annotation);
//            if (rg == null) throw (new Exception($"寄存器地址{annotation}未定义！"));
//            return rg;
//        }

//        public static BitDataRegister GetOut_BitDataRegister(string annotation)
//        {
//            var rg = Out_PiyshicalBitDataRegisters.Values.FirstOrDefault(x => x.Annotation == annotation);
//            if (rg == null) throw (new Exception($"寄存器地址{annotation}未定义！"));
//            return rg;
//        }
//    }
//}
